package run;

import java.awt.Color;
import java.awt.Container;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.Timer;

@SuppressWarnings("serial")
public class AboutForm extends JDialog
{
	private Timer tim;
	private ImageIcon img;
	private ImageIcon icon;
	private JPanel panel;
	private int offsety;
	
	public AboutForm(Container parent)
	{		
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		setSize(640, 240);
		setResizable(false);
		setTitle(LanguageLoader.currentLang.language.aboutGui.title + " VKMediaCrawler");
		setLocation(Math.abs((getWidth() - parent.getWidth()) / 2), Math.abs((getHeight() - parent.getHeight()) / 2));
		setLocationRelativeTo(parent);
		setLayout(null);
		setModal(true);
		
		offsety = getHeight();
		
		panel = new JPanel(){
			public void paintComponent(Graphics g)
			{
				super.paintComponent(g);
				g.drawImage(img.getImage(), 0, 0, null);
				
				g.setColor(new Color(0, 0, 0, 80));
				g.fillRect(0, offsety, getWidth(), getHeight());
				
				g.drawImage(icon.getImage(), 5, offsety + 5, null);
				
				g.setFont(new Font("Verdana", Font.BOLD, 35));
				
				g.setColor(new Color(20, 20, 20));
				g.drawString("VKMediaCrawler", 82, offsety + 52);
				g.setColor(new Color(50, 140, 200));
				g.drawString("VKMediaCrawler", 80, offsety + 50);
				
				g.setFont(new Font("Verdana", Font.BOLD, 25));
				
				g.setColor(new Color(20, 20, 20));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.subtitle, 11, offsety + 96);
				g.setColor(new Color(110, 160, 180));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.subtitle, 10, offsety + 95);

				g.setFont(new Font("Verdana", Font.BOLD, 18));
				
				g.setColor(new Color(20, 20, 20));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.developer + ":    Exit93 (tr3nx4n)  " + LanguageLoader.currentLang.language.aboutGui.and + " Syl4r93", 6, offsety + 141);
				g.setColor(new Color(245, 245, 245));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.developer + ":    Exit93 (tr3nx4n)  " + LanguageLoader.currentLang.language.aboutGui.and + " Syl4r93", 5, offsety + 140);
				
				g.setColor(new Color(20, 20, 20));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.email + ":    sylar__93__@hotmail.it", 6, offsety + 171);
				g.setColor(new Color(245, 245, 245));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.email + ":    sylar__93__@hotmail.it", 5, offsety + 170);
				
				g.setColor(new Color(20, 20, 20));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.homepage + ":    https://code.google.com/p/vk-media-crawler/", 6, offsety + 201);
				g.setColor(new Color(245, 245, 245));
				g.drawString(LanguageLoader.currentLang.language.aboutGui.homepage + ":    https://code.google.com/p/vk-media-crawler/", 5, offsety + 200);
			}
		};
		panel.setBounds(0, 0, getWidth(), getHeight());
		add(panel);
		
		java.net.URL imgURL = getClass().getResource("/res/about_bg.png");
		img = new ImageIcon(imgURL);
		
		imgURL = getClass().getResource("/res/icon.png");
		icon = new ImageIcon(imgURL);
		
		tim = new Timer(30, new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				if (offsety > -(getHeight() + 20))
					offsety--;
				else
					offsety = getHeight();
				panel.repaint();
			}
		});
		tim.start();
		
		setVisible(true);
	}
}
